# @Time : 2020/7/27 14:57
# @Author : Fioman 
# @Phone : 13149920693
import cv2 as cv
import numpy as np

"""
闭运算,是先膨胀,再腐蚀.它可以关闭前景物体的内部小孔,或者去除物体上的小黑点.可以将不同的前景图像进行连接.
"""

img = cv.imread("test.bmp", cv.IMREAD_GRAYSCALE)
cv.imshow("Original", img)
T, thres = cv.threshold(img, 0, 255, cv.THRESH_BINARY | cv.THRESH_OTSU)
cv.imshow("Thres",thres)

kernel = np.ones((10,10),dtype=np.uint8)
closing = cv.morphologyEx(thres,cv.MORPH_CLOSE,kernel,iterations=1)
cv.imshow("Closed",closing)

cv.waitKey(0)
























